home *** CD-ROM | disk | FTP | other *** search
- // Documentation & updates available at:
- // http://codecentre.eplica.is/js/eolasfix/test.htm
-
- (function ()
- {
- // run only once!
- if (window.__Eolas_Fixed) { return; }
- __Eolas_Fixed = 1;
-
- var doc = document, // minifier alias
- getElementsByTagName = 'getElementsByTagName', // minifier alias
- outerHTML = 'outerHTML', // minifier alias
- // tags = ['object','embed','applet'], // tags to "fix"
- tags = ['embed'],
- x = -1, y, z,
- elm, paramElm, paramsHTML,
- elements, element_tags
-
- eolasfix = function ()
- {
- // for each tag name specified in Array t
- elements = doc [getElementsByTagName]
- while (tags [++x])
- {
- // find all elements of that type in the document
- // loop through the elements
- element_tags = elements (tags[x]);
- y = 0;
- while (elm = element_tags [y++])
- {
- paramsHTML = "";
- z = 0;
- // sometimes <param> elements don't show up in innerHTML
- // if (!/<p/i.test(elm[outerHTML]))
- // {
- // // and then we need to collect their outerHTML.
- // while (paramElm = elements('param')[z++])
- // {
- // paramsHTML += paramElm[outerHTML];
- // }
- // }
- // Then clone and replace the `elm` in the DOM and insert `paramHTML`.
- elm[outerHTML] = elm[outerHTML].replace(/>/, '>'+paramsHTML);
- }
- }
- };
-
- 0/*@cc_on + 1 @*/ && eolasfix();
- // if is_ie, then run the fix straight away
- // (because the defer="defer" attribute has delayed
- // execution until the DOM has loaded)
- window.opera && doc.addEventListener('DOMContentLoaded', eolasfix, 0);
- // else if we're running Opera, then set an
- // `DOMContentLoaded` event to run the fix.
-
- })();
-